﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FTBS.Models.DAO;
using FTBS.Models.Entities;
using System.Transactions;

namespace FTBS.Models.BLO
{
    public class ChairBLO
    {
        private ChairDAO _chairDao = new ChairDAO();
        private TicketDAO _ticketDao = new TicketDAO();

        /// <summary>
        /// load chair by rooom Id
        /// </summary>
        /// <param name="roomId"></param>
        /// <returns></returns>
        /// <author>hungph</author>
        public List<Chair> LoadChairs(int roomId)
        {
            var listChair = _chairDao.LoadChairs(roomId);
            return listChair;
        }

        /// <summary>
        /// load chair by rooom Id and Isdeleted = false
        /// </summary>
        /// <param name="roomId"></param>
        /// <returns></returns>
        /// <author>hungph</author>
        public List<Chair> LoadChairsWithIsdeletedEqualFalse(int roomId)
        {
            var listChair = _chairDao.LoadAllChairs(roomId);
            return listChair;
        }

        ///// <summary>
        ///// update chair
        ///// </summary>
        ///// <param name="listId"></param>
        ///// <author>???</author>
        //public void UpdateChair(string listId)
        //{
        //    string[] listChair = listId.Split(' ');
        //    foreach (string chair in listChair)
        //    {
        //        _chairDao.UpdateChair(int.Parse(chair));
        //    }
        //}

        /// <summary>
        /// get chair by id
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        /// <author>hungph</author>
        public Chair GetChairById(int id)
        {
            var chair = _chairDao.GetChairById(id);
            return chair;
        }

        /// <summary>
        /// get chair by id
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        /// <author>hungph</author>
        public Chair GetChairByIdWithoutIsdeleted(int id)
        {
            var chair = _chairDao.GetChairByIdWithoutCheckingIsDeleted(id);
            return chair;
        }

        /// <summary>
        /// Add an array chairs of a room
        /// </summary>
        /// <param name="strChair"></param>
        /// <param name="id"></param>
        /// <param name="strChairType"></param>
        /// <returns></returns>
        /// <author>nguyenht</author>
        public int AddChairs(string[] strChair, int id, string[] strChairType,string[] AstrChair)
        {
           
           if(_chairDao.AddChair(strChair, id,  strChairType, AstrChair)){
           return 1;
           }
           return 0;
        }
        
        public int EditChairs(string[] strChair, int id, string[] strChairType)
        {
            if(_chairDao.Edit( strChair,  id, strChairType)){
                return 1;
            }
            return 0;
        }
        public bool CheckIsTicket(int id) {
            return(_ticketDao.CheckTicket(id));
        }

    }
}